﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

//Author: ljj
//Date: 20190710
//Function: 拾起宝石后移速减慢,并且无法攻击
public class CatchGoalSlow : BaseBuff
{
    public override void BuffUp()
    {
        //Debug.Log("Up" + effect);
        UpdateSpeed(effect);
        gameObject.GetComponent<BattleObject>().stopAttack++;
    }

    public override void BuffDown()
    {
        //Debug.Log("Down" + effect);
        UpdateSpeed(1 / effect);
        gameObject.GetComponent<BattleObject>().stopAttack--;
    }

    void UpdateSpeed(float effect)
    {
        Move move = gameObject.GetComponent<Move>();
        if (move != null) 
            move.speed /= effect;
        Player player = gameObject.GetComponent<Player>();
        if (player != null)
            player.speed /= effect;
    }
}
